package com.hl.sfzy.controller;

import com.hl.sfzy.service.LogonAdminService;
import com.hl.sfzy.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: sfzy
 * @description: 孙源源-管理员登录
 * @author: Syy
 * @create: 2024-09-06 16:03
 **/
@RestController
@RequestMapping("/admin")
public class LogonAdminController {
    @Autowired
    private LogonAdminService logonAdminService;

    //登录接口
    @GetMapping("/logon")
    public R logon(String identifier, String password) {
        int i = logonAdminService.logon(identifier, password);
        if (i == 1) {
            //登录成功返回1
            return R.success(i);
        } else {
            //登录失败返回-1(用户名不存在或role不为1即不是用户)或0(密码错误)
            return R.failure(i);
        }
    }
}
